import request from '@/router/axios';
import {baseUrl} from '@/config/env';

export const userPage = (current, size, params) => {
  return request({
    url: baseUrl + '/api-user/users/userPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const userList = () => {
  return request({
    url: baseUrl + '/api-user/users/list',
    method: 'get'
  })
}

export const remove = (ids) => {
  return request({
    url: baseUrl + '/api-user/users/remove/'+ids,
    method: 'post',
    // params: {
    //   ids,
    // }
  })
}

export const create = (row) => {
  return request({
    url: baseUrl + '/api-user/users/create',
    method: 'post',
    data: row,
    params: {
      tenantId: row.tenantId
    }
  })
}

export const update = (row) => {
  return request({
    url: baseUrl + '/api-user/users/update',
    method: 'post',
    data: row
  })
}

export const grant = (userId, roleIds) => {
  return request({
    url: baseUrl + '/api-user/users/grantUserRoles',
    method: 'post',
    params: {
      userId,
    },
    data: {
      roleIds
    }
  })
}

export const getUser = (id) => {
  return request({
    url: baseUrl + '/api-user/users/userId/' + id,
    method: 'get'
  })
}

export const getUserInfo = () => {
  return request({
    url: baseUrl + '/api-user/users/current',
    method: 'get',
  })
}

export const resetPassword = (userIds) => {
  return request({
    url: '/api/blade-user/reset-password',
    method: 'post',
    params: {
      userIds,
    }
  })
}

export const updatePassword = (oldPassword, newPassword, newPassword1) => {
  return request({
    url: '/api/blade-user/update-password',
    method: 'post',
    params: {
      oldPassword,
      newPassword,
      newPassword1,
    }
  })
}

export const exportUser = (oldPassword, newPassword, newPassword1) => {
  return request({
    url: baseUrl + "/api-user/users/export",
    method: 'post',
  })
}

